﻿using System;
using System.ComponentModel;

namespace Oxage.Common
{
	public class ViewHelper
	{
		public static void Dispatch(Action callback)
		{
			//Invoke in GUI thread
			App.ViewModel.View.Dispatcher.Invoke((CrossThreadDelegate)delegate
			{
				callback();
			});
		}

		public static void RunInBackground(Action action)
		{
			var worker = new BackgroundWorker();
			worker.DoWork += (a, b) =>
			{
				action();
			};
			worker.RunWorkerAsync();
		}
	}
}
